import requests

# Jenkins 服务器的 URL
jenkins_url = 'https://jenkins.cfhy.work'
# Jenkins 用户名和 API 密钥（用于身份验证）
username = 'siyuxiang'
api_token = 'Tianyi456'

# 构建 API 请求的 URL
api_url = f"{jenkins_url}/api/json"

# 使用 Basic Auth 进行身份验证
response = requests.get(api_url, auth=(username, api_token))

# 检查请求是否成功
if response.status_code == 200:
    # 提取所有作业的信息
    jobs_info = response.json()['jobs']
    count = 0
    for job in jobs_info:
        count += 1
        print(f"Job Name: {job['name']}, URL: {job['url']}")
        print(count)
else:
    print("Failed to retrieve jobs information.")